<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">全部物资</view>
		</stop>
		<view class="bcf padlr3 padtb2 bdtso mart3 flrc">
			<view class="flex1">
				<search class="fs8 tac" placeholder=" 单号 \ 物资名称 \ 编码 \ 型号"  v-model="search" @search="doSearch()"></search>
			</view>
			<view class="marl3">
				<view class="cu-btn round bg-green" @tap="goto('/pages/store/store_item_form')">
					新增
					<ripple></ripple>
				</view>
			</view>
		</view>
		
		<view class="flrc bcf pad3 bdtso bdbso fs8">
			<view class="flex1"><scondition @input="reload()" model="MachineCategory" v-model="where.eq.category" label="物资类别"></scondition></view>
			<view class="flex1"><scondition @input="reload()" model="MachineGroup" v-model="where.eq.unit" label="计量单位"></scondition></view>
		</view>
		<view class="padlr3">
			<view class="bcf pos-r mart3 pad2 round2 shadow" @tap="goto('/pages/store/store_item_form?id=' + item.id)"
			v-for="item in data" :key="item.id">
				<store-item :item="item"></store-item>
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../assets/js/list.js'
	
	import storeItem from '../../templete/store/store_item.vue'
	
	export default {
		mixins:[MescrollMixin],
		components:{storeItem},
		data() {
			let list = new List()
			return {
				list,
				where:{
					eq:{
						category:'',
						unit:''
					}
				},
				search:"",
				data:[]
			}
		},
		methods: {
			reload(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			confirm(id){
				this.goto('/pages/store/store_in_check_form?id=' + id)
			},
			deleteIt(id){
				this.$api.delete('/api/storeIns/'+id,{},res=>{
					this.log(res)
					this.reload()
				})
			}
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/storeItems').setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.log("onshow")
			this.showLoading()
			this.list.reload()
		},
		watch:{
		}
	}
</script>

<style>

</style>
